﻿var loadingAnimationTemplate = '<div id="circularG">' +
'<div id="circularG_1" class="circularG"></div>' +
'<div id="circularG_2" class="circularG"></div>' +
'<div id="circularG_3" class="circularG"></div>' +
'<div id="circularG_4" class="circularG"></div>' +
'<div id="circularG_5" class="circularG"></div>' +
'<div id="circularG_6" class="circularG"></div>' +
'<div id="circularG_7" class="circularG"></div>' +
'<div id="circularG_8" class="circularG"></div>' +
'</div>';

var message = '<span id="loadingMessage">Veuillez patienter un instant...</span>';

var loadingAnimation = null;

var userEditTemplate = '<div id="userEditTemplate">' +
                                '<div class="loginLabelTextBox">' +
                                    '<label class="labelLogin">Utilisateur</label>' +
                                    '<div id="usernameEdit" class="input-control text textBoxLogin">' +
                                        '<input id="usernameEditInput" type="text" />' +
                                        '<button class="btn-clear"></button' +
                                     '</div>' +
                                '</div>' +
                            '</div>';
var loadingWindow = null;

function showLoadingAnimation(height, width, contentTemplate) {


    $.Dialog({
        overlay: true,
        shadow: true,
        flat: true,
        height: height,
        width: width,
        sysButtons: {
            btnClose: false
        },
        overlayClickClose: false,
        content: contentTemplate
    });

    loadingAnimation = $(".window-overlay");
    loadingAnimation.attr("id", "loadingAnimationWindowsOverlay");

    loadingWindow = $(".window").attr("id", "loadingWindow");

    var title = $(".caption");
    title.attr("id", "loadingAnimationCaption");

    var content = $(".content");
    var contentClass = $(".content").attr("class").split(" ");

    if (contentClass.length === 1) {
        content.attr("id", "loadingAnimationContent");
        content.css("height", height + "px");
        content.css("width", width + "px");

        title.css("display", "none");
        content.addClass("loadingFont");
        content.css("background-color", "rgba(0, 0, 0, 0.7)");
        return;
    }
    content.addClass("dialogFont");
}

function hideLoadingAnimation() {
    $.Dialog.close();
}



function updateLoadingAnimation(height, width, contentTemplate) {
    $("#loadingMessage").html(contentTemplate);
    loadingWindow.css("height", height + "px");
    loadingWindow.css("min-height", height + "px");
    loadingWindow.css("width", width + "px");
    loadingWindow.css("min-width", width + "px");

    var loadingAnimationContent = $("#loadingAnimationContent");
    loadingAnimationContent.css("height", height + "px");
    loadingAnimationContent.css("width", width + "px");

    var content = $(".content");
    var contentClass = $(".content").attr("class").split(" ");

    if (contentClass.length === 1) {
        content.css("height", height + "px");
        content.css("width", width + "px");
    }
}